<%@page import="dto.postScriptDTO"%>
<%@page import="dto.MemberDTO"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<!-- jquery로 후기등록 이미지 버튼을 만들어야 한다 -->
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>후기등록 페이지</title>

<script type="text/javascript">


var cnt = 1;
var flag1 = 1;
var flag2 = 1;
var flag3 = 1;
var flag4 = 1;
var flag5 = 1;
function inputForm(){
	var form = document.form1;
	form.action = "/Project_homeshare_room/postScriptWriteController.do";
	form.method = "post";
	var cnt1 = cnt;
	var score1 = document.getElementById("score");
	document.getElementById("score").value=cnt1;
	form.submit();	
}
function inputScore(){
	var td = document.getElementById("good");
	while(td.hasChildNodes()){
		td.removeChild(td.firstChild);
	}
	
	 
	
	var newP = document.createElement("p");//엘리먼트 노ㅇ드 생성
	var img1 = document.createElement("img");//이미지 생성
	var img2 = document.createElement("img");
	var img3 = document.createElement("img");
	var img4 = document.createElement("img");
	var img5 = document.createElement("img");
	img1.setAttribute("src", "/${initParam.context_root }/goldstar.jpg");
	img1.setAttribute("onclick", "inputScore()");
	img2.setAttribute("src", "/${initParam.context_root }/whitestar.png");
	img2.setAttribute("onclick", "inputScore2()");
	img3.setAttribute("src", "/${initParam.context_root }/whitestar.png");
	img3.setAttribute("onclick", "inputScore3()");
	img4.setAttribute("src", "/${initParam.context_root }/whitestar.png");
	img4.setAttribute("onclick", "inputScore4()");
	img5.setAttribute("src", "/${initParam.context_root }/whitestar.png");
	img5.setAttribute("onclick", "inputScore5()");
	
 	newP.appendChild(img1);
 	newP.appendChild(img2);
 	newP.appendChild(img3);
 	newP.appendChild(img4);
 	newP.appendChild(img5);
	cnt = 1;
	var rootDiv = document.getElementById("good");//Div태그를 갖고옴
	rootDiv.appendChild(newP);
	
}
function inputScore2(){
	var td = document.getElementById("good");
	while(td.hasChildNodes()){
		td.removeChild(td.firstChild);
	}
	
	
	
	
	var newP = document.createElement("p");//엘리먼트 노ㅇ드 생성
	var img1 = document.createElement("img");//이미지 생성
	var img2 = document.createElement("img");
	var img3 = document.createElement("img");
	var img4 = document.createElement("img");
	var img5 = document.createElement("img");
	img1.setAttribute("src", "/${initParam.context_root }/goldstar.jpg");
	img1.setAttribute("onclick", "inputScore()");
	img2.setAttribute("src", "/${initParam.context_root }/goldstar.jpg");
	img2.setAttribute("onclick", "inputScore2()");
	img3.setAttribute("src", "/${initParam.context_root }/whitestar.png");
	img3.setAttribute("onclick", "inputScore3()");
	img4.setAttribute("src", "/${initParam.context_root }/whitestar.png");
	img4.setAttribute("onclick", "inputScore4()");
	img5.setAttribute("src", "/${initParam.context_root }/whitestar.png");
	img5.setAttribute("onclick", "inputScore5()");
 	newP.appendChild(img1);
 	newP.appendChild(img2);
 	newP.appendChild(img3);
 	newP.appendChild(img4);
 	newP.appendChild(img5);
	cnt = 2;
	var rootDiv = document.getElementById("good");//Div태그를 갖고옴
	rootDiv.appendChild(newP);
}
function inputScore3(){
	var td = document.getElementById("good");
	while(td.hasChildNodes()){
		td.removeChild(td.firstChild);
	}
	
		
	
	
	var newP = document.createElement("p");//엘리먼트 노ㅇ드 생성
	var img1 = document.createElement("img");//이미지 생성
	var img2 = document.createElement("img");
	var img3 = document.createElement("img");
	var img4 = document.createElement("img");
	var img5 = document.createElement("img");
	img1.setAttribute("src", "/${initParam.context_root }/goldstar.jpg");
	img1.setAttribute("onclick", "inputScore()");
	img2.setAttribute("src", "/${initParam.context_root }/goldstar.jpg");
	img2.setAttribute("onclick", "inputScore2()");
	img3.setAttribute("src", "/${initParam.context_root }/goldstar.jpg");
	img3.setAttribute("onclick", "inputScore3()");
	img4.setAttribute("src", "/${initParam.context_root }/whitestar.png");
	img4.setAttribute("onclick", "inputScore4()");
	img5.setAttribute("src", "/${initParam.context_root }/whitestar.png");
	img5.setAttribute("onclick", "inputScore5()");
 	newP.appendChild(img1);
 	newP.appendChild(img2);
 	newP.appendChild(img3);
 	newP.appendChild(img4);
 	newP.appendChild(img5);
 	cnt = 3;
	var rootDiv = document.getElementById("good");//Div태그를 갖고옴
	rootDiv.appendChild(newP);
}
function inputScore4(){
	var td = document.getElementById("good");
	while(td.hasChildNodes()){
		td.removeChild(td.firstChild);
	}
	
		
	
	
	var newP = document.createElement("p");//엘리먼트 노ㅇ드 생성
	var img1 = document.createElement("img");//이미지 생성
	var img2 = document.createElement("img");
	var img3 = document.createElement("img");
	var img4 = document.createElement("img");
	var img5 = document.createElement("img");
	img1.setAttribute("src", "/${initParam.context_root }/goldstar.jpg");
	img1.setAttribute("onclick", "inputScore()");
	img2.setAttribute("src", "/${initParam.context_root }/goldstar.jpg");
	img2.setAttribute("onclick", "inputScore2()");
	img3.setAttribute("src", "/${initParam.context_root }/goldstar.jpg");
	img3.setAttribute("onclick", "inputScore3()");
	img4.setAttribute("src", "/${initParam.context_root }/goldstar.jpg");
	img4.setAttribute("onclick", "inputScore4()");
	img5.setAttribute("src", "/${initParam.context_root }/whitestar.png");
	img5.setAttribute("onclick", "inputScore5()");
 	newP.appendChild(img1);
 	newP.appendChild(img2);
 	newP.appendChild(img3);
 	newP.appendChild(img4);
 	newP.appendChild(img5);
 	cnt = 4;
	var rootDiv = document.getElementById("good");//Div태그를 갖고옴
	rootDiv.appendChild(newP);
}
function inputScore5(){
	var td = document.getElementById("good");
	while(td.hasChildNodes()){
		td.removeChild(td.firstChild);
	}

	
	
	var newP = document.createElement("p");//엘리먼트 노ㅇ드 생성
	var img1 = document.createElement("img");//이미지 생성
	var img2 = document.createElement("img");
	var img3 = document.createElement("img");
	var img4 = document.createElement("img");
	var img5 = document.createElement("img");
	img1.setAttribute("src", "/${initParam.context_root }/goldstar.jpg");
	img1.setAttribute("onclick", "inputScore()");
	img2.setAttribute("src", "/${initParam.context_root }/goldstar.jpg");
	img2.setAttribute("onclick", "inputScore2()");
	img3.setAttribute("src", "/${initParam.context_root }/goldstar.jpg");//	img3.setAttribute("onclick", "inputScore3()");
	img2.setAttribute("onclick", "inputScore3()");
	img4.setAttribute("src", "/${initParam.context_root }/goldstar.jpg");
	img4.setAttribute("onclick", "inputScore4()");
	img5.setAttribute("src", "/${initParam.context_root }/goldstar.jpg");
	img5.setAttribute("onclick", "inputScore5()");
 	newP.appendChild(img1);
 	newP.appendChild(img2);
 	newP.appendChild(img3);
 	newP.appendChild(img4);
 	newP.appendChild(img5);
 	cnt = 5;
	var rootDiv = document.getElementById("good");//Div태그를 갖고옴
	rootDiv.appendChild(newP);
}

</script>
</head>
<body>
<%postScriptDTO pdto = (postScriptDTO)request.getAttribute("pdto"); %>


<c:set var="dto" scope="session" value='<%= (MemberDTO)session.getAttribute("login_info")%>'/>
<%-- <form action="/${initParam.context_root }/postScriptWriteController.do" method="post"> --%>
<form name="form1">
<!-- postScriptWriteController.do로 요청해야 한다. -->
<table border="1">
<tr>

<td><c:if test="${sessionScope.dto.picture_filename != null}">
	<img src="/${initParam.context_root }/member_picture/<%=pdto.getPicture_filename() %>" width="100" > <br>
</c:if></td>
<td rowspan="3" ><textarea rows="10" cols="30" name="postScript_content"></textarea></td>
<td id = "go" rowspan="2" align="center">
<%-- <a href="javascript:inputForm()"><img src="/${initParam.context_root }/postScript.PNG"></a> --%>
<img src="/${initParam.context_root }/postScript.PNG" 
	  id ="btn" onClick="inputForm()">

</td>
</tr>
<tr>
<td>${sessionScope.dto.member_id}</td>
<input type="hidden" name="postScript_memberid" value="${sessionScope.dto.member_id}">
</tr>
<tr>
<td>작성일자</td>
<td id="good">
<img src="/${initParam.context_root }/goldstar.jpg" onClick="inputScore()" id="e1">
<img src="/${initParam.context_root }/whitestar.png" onClick="inputScore2()" id="e2">
<img src="/${initParam.context_root }/whitestar.png" onClick="inputScore3()" id="e3">
<img src="/${initParam.context_root }/whitestar.png" onClick="inputScore4()" id="e4">
<img src="/${initParam.context_root }/whitestar.png" onClick="inputScore5()" id="e5">

<%-- <a href="javascript:inputScore()"><img src="/${initParam.context_root }/score.PNG" onClick="disable()" id="ee"></a> --%>

</td>
</tr>
</table>

<input type="hidden" id="score" name="score">

</form>
</body>
</html>